﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Scrabble.Model.Tests
{
    [TestClass]
    public class BasicTests
    {
        [TestMethod]
        public void ThatValidNotationForAcrossPlayIsParsedCorrectly()
        {
            var play = PlayVector.Parse("A15");
            Assert.AreEqual(0, play.StartingLocation.Column);
            Assert.AreEqual(14, play.StartingLocation.Row);
            Assert.IsFalse(play.IsAcross);
        }

        [TestMethod]
        public void ThatValidNotationForDownPlayIsParsedCorrectly()
        {
            var play = PlayVector.Parse("9H");
            Assert.AreEqual(7, play.StartingLocation.Column);
            Assert.AreEqual(8, play.StartingLocation.Row);
            Assert.IsTrue(play.IsAcross);
        }

        [TestMethod]
        public void ThatAcrossPlayAsStringIsCorrect()
        {
            var play = new PlayVector { IsAcross = false, StartingLocation = new BoardLocation(5, 3) };
            Assert.AreEqual("F4", play.ToString());
        }

        [TestMethod]
        public void ThatDownPlayAsStringIsCorrect()
        {
            var play = new PlayVector { IsAcross = true, StartingLocation = new BoardLocation(0, 6) };
            Assert.AreEqual("7A", play.ToString());
        }

        [TestMethod]
        public void ThatInvalidColumnInPlayNotationReturnsNull()
        {
            var play = PlayVector.Parse("A16");
            Assert.IsNull(play);
        }

        [TestMethod]
        public void ThatInvalidRowInPlayNotationReturnsNull()
        {
            var play = PlayVector.Parse("Q4");
            Assert.IsNull(play);
        }
    }
}
